package com.qf.service.impl;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheRemove;
import com.netflix.hystrix.contrib.javanica.cache.annotation.CacheResult;
import com.qf.feign.GoodsFeign;
import com.qf.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author YDW
 * projectName:project2202_4
 * time:2022/6/14 21:26
 * description:
 */
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    GoodsFeign goodsFeign;
    @Override
    @CacheResult
    @HystrixCommand(commandKey = "test_cache")
    public String testCache(Integer id) {
        return goodsFeign.get(id);
    }

    @Override
    @HystrixCommand
    @CacheRemove(commandKey = "test_cache")
    public void clearCache(Integer id) {
        System.out.println("清除缓存");
    }
}
